package com.pay.web.utils;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

/**
 * Created by chenweiyi on 2018/2/5.
 */
public class GsonUtils {

    /**
     * json字符串转对象
     * @param json
     * @param clazz
     * @param <T>
     * @return
     */
    public static <T> T fromJson(String json,Class<T> clazz){
        Gson gson = new Gson();
        return  gson.fromJson(json,clazz);
    }

    /**
     *对象转json字符串
     * @param object
     * @return
     */
    public static String toJson(Object object){
        Gson gson = new Gson();
        return gson.toJson(object);
    }
}
